package com.zzj.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzj.entity.Hospital;
import com.zzj.mapper.HospitalMapper;
import com.zzj.service.IHospitalService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 医院 服务实现类
 * </p>
 *
 * @author zzj
 * @since 2023-05-12
 */
@Service
public class HospitalServiceImpl extends ServiceImpl<HospitalMapper, Hospital> implements IHospitalService {

    @Override
    public void like(int id) {
        this.lambdaUpdate()
                .eq(Hospital::getId, id)
                .setSql("like_count = like_count + 1").update();
    }

    @Override
    public void dislike(int id) {
        this.lambdaUpdate()
                .eq(Hospital::getId, id)
                .setSql("like_count = like_count - 1").update();
    }

    @Override
    public Hospital id(int id) {
        return this.getOne(Wrappers.<Hospital>lambdaQuery()
                        .eq(Hospital::getId, id),
                false);
    }
}
